def isrootN(num, n: int):
    '''
    num = xxx.xxxxxxx, with limited digits
    if num^(1/n) is rational number, return True, or False
    [NOTE] num can not be writed as p/q, 
    because float computing is inaccuracy in Python
    '''

    if int(num) == num:
        root = num**(1/n)

        return num in {int(root)**n,(int(root)+1)**n}
        # handle the cases, 
        # root = 1.000000000003, or root = 5.999999997
    else:
        ns = str(num).strip('0').split('.')
        ns[1] += '0'*(n - len(ns[1]) % n if len(ns[1]) % n else 0)


        return isrootN(int(ns[0]+ns[1]),n)


def isSquare(num):
    return isrootN(num, 2)


def isCubic(num):
    return isrootN(num, 3)


if __name__ == '__main__':

    assert all([isrootN(0.0010, 3),
                isrootN(0.0001, 4),
                isSquare(1.21),
                isCubic(1.86086700),
                not isSquare(1/9)])
